﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


using FXnaGis;

using DotSpatial.Topology;



namespace NSCore
{
    /// <summary>
    /// 用于捕捉上下文参数
    /// 这里我们使用它来传递公共参数
    /// </summary>
    public class NSContext
    {
        public NSContext(NSData data,TimeDivision division)
        {

            this._sources = new MathSources();

            this._currentDivision = division;


            this.InitSources(data,division);






 
        }


        TimeDivision _currentDivision;

        public TimeDivision CurrentDivision
        {
            get { return _currentDivision; }
          
        }





        protected void InitSources(NSData data, TimeDivision division)
        {

            //这里我们需要整理所有的发声源

            //我们需要在这里去掉不必要的界面表现部分等内容


            List<MathPS> lstMathPs = new List<MathPS>();



            foreach (FShape shp in data.PtLayer.Shapes.Values)
            {
                PointSource ps = shp as PointSource;





                //获取需要的噪声级
                NoiseLevel level = ps.TimedNoiseLevels[division];


                double w = 0;

                if (level.BandMode1 == NoiseLevel.BandMode.SingleBand)
                {
                    w = level.Lw;

                }

                else
                {
                    w = level.LAw;


                }

                MathPS mathPs = new MathPS((Coordinate)ps.InnerShape.Point.Coordinate.Clone(), w);

                if (ps.IsReference)
                {
                    mathPs.IsReference = true;

                    mathPs.NoiseDistance = ps.NoiseDistance;



                }


                lstMathPs.Add(mathPs);




            }



            this.Sources.LstMathPs.AddRange(lstMathPs);


        }


        MathSources _sources;

        public MathSources Sources
        {
            get { return _sources; }
           
        }




    }
}
